﻿using Api1.Util;
using System;
using System.Collections.Generic;

namespace Api1.Service
{
    /// <summary>
    /// 安科接口服务类
    /// </summary>
    public class OcmApiService
    {
        public static OcmApiService instance;
        /// <summary>
        /// api 类型 1 安科 2勤鸟  3 捷径  4东夏  5单机版 6自由岛
        /// </summary>
        public static String api_type = OperateIniFile.ReadIniData("APITYPE", "Type", "1");

        public OcmApiService() {
        }
        public static OcmApiService GetInstance() {
            if (instance == null) {
                instance = new OcmApiService();
            }
            return instance;
        }

        /// <summary>
        ///  根据卡号获取合同编号
        /// </summary>
        /// <param name="Card_No"></param>
        /// <returns></returns>
        public Dictionary<String, Object> GetContractInfo(String Card_No) {
            if (api_type.Equals("1"))
            {
                return AKApiService.GetInstance().GetContractInfo(Card_No);
            }
            else if (api_type.Equals("4"))
            {
                return DXApiService.GetInstance().GetContractInfo(Card_No);
            }
            else if (api_type.Equals("5"))
            {
                // return SingleVersionService.GetInstance().GetContractInfo(Card_No);
                return HttpClient.Error("本地数据，无需同步");
            }

            return HttpClient.Error("错误的api 类型");
        }
        /// <summary>
        /// 入场操作
        /// </summary>
        /// <param name="ContractID"></param>
        /// <param name="MemberID"></param>
        /// <returns></returns>
        public Dictionary<String, Object> CheckIn(String ContractID,String MemberID,String CardNo) {
            if (api_type.Equals("1"))
            {
                return AKApiService.GetInstance().CheckIn(ContractID, MemberID);
            }
            else if (api_type.Equals("4"))
            {
                return DXApiService.GetInstance().CheckIn(CardNo);
            }
            else if (api_type.Equals("5"))
            {
                return SingleVersionService.GetInstance().CheckIn(CardNo);
            }
            return HttpClient.Error("错误的api 类型");
        }
        /// <summary>
        /// 出场操作
        /// </summary>
        /// <param name="CardNo"></param>
        /// <returns></returns>
        public Dictionary<String, Object> CheckOut(String CardNo) {
            if (api_type.Equals("1"))
            {
                return AKApiService.GetInstance().CheckOut(CardNo);
            }
            else if (api_type.Equals("4"))
            {
                return DXApiService.GetInstance().CheckOut(CardNo);
            }
            else if (api_type.Equals("5"))
            {
                return SingleVersionService.GetInstance().CheckOut(CardNo);
            }
            return HttpClient.Error("错误的api 类型");
        }
    }
}
